package kuoge.practice.hash.consistenthash;

import java.util.Objects;

public final class Node {
    private String ip;
    private boolean valid;

    public Node(String ip, boolean valid) {
        this.ip = ip;
        this.valid = valid;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public boolean isValid() {
        return valid;
    }

    public void setValid(boolean valid) {
        this.valid = valid;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Node node = (Node) o;
        return valid == node.valid && ip.equals(node.ip);
    }

    @Override
    public int hashCode() {
        return Objects.hash(ip, valid);
    }
}
